#pragma once

#include <iostream>
#include <sys/epoll.h>

const int gnum = 128;

class Epoll
{
public:
    Epoll()
    {}

    void CreateEpoll()
    {
        _epfd = epoll_create(gnum);
        if (_epfd < 0) exit(5);
    }

    bool AddSockToEpoll(int sock, uint32_t events)
    {
        struct epoll_event ev;
        ev.data.fd = sock;
        ev.events = events;
        int n = epoll_ctl(_epfd, EPOLL_CTL_ADD, sock, &ev);
        return n == 0;
    }

    ~Epoll()
    {}
private:
    int _epfd;
};